package com.lc.java.ai.langchain4j.controller;

import com.lc.java.ai.langchain4j.assistant.XiaoZhiAgent;
import com.lc.java.ai.langchain4j.domain.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author liuchun
 * @version 1.0
 * @date 2025/6/5 20:40
 */
@RestController
@RequestMapping("/xiaozhi")
@Tag(name = "硅谷小智")
public class XiaoZhiController {

    @Autowired
    private XiaoZhiAgent xiaoZhiAgent;

    @PostMapping(value = "/chat",produces = "text/stream;charset=utf-8")
    @Operation(summary = "小智对话")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        return xiaoZhiAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }
}
